﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

using Microsoft.Web.Administration;

using King.Extensions;
using King.Reflection;
using King.Text;
using King.Automation;


namespace ConsoleApplication1 {
    public class Program {
        public static object Any(params object[] o) {
            return o;
        }
        public static object Any(object a0 = null, object a2 = null, object a3 = null) {
            return null;
        }
    }
}
namespace King.Automation.InternetInformationService {
    
    public class Program {

        int i;

        public class Bar { } 

        public static int Main(string[] args) {
            return ConsoleApplication.EntryPoint(args);
        }
        public static int Main2(string[] args) {
            return ConsoleApplication.EntryPoint(args);
        }

        
    } 

    ///// <summary>
    ///// Application Pool 
    ///// </summary>
    //[Command, TextNodeHasSideEffect, TextNodeContainsState]
    //public abstract class AppPoolCommand : Command {
    //}

    //[Command]
    //public class AppPool : Command {

    //    private enum Verb {
    //        Update,
    //        Add,
    //        Remove,
    //        Recycle,
    //        Start,
    //        Stop,
    //    }
    //    public enum Version {
    //        None,
    //        v2,
    //        v4,
    //    }
    //    public enum PipelineMode {
    //        Classic,
    //        Integrated,
    //    }
    //    public enum LimitAction {
    //        NoAction,
    //        KillW3WP,
    //    }
    //    public enum ServiceUnavailable {
    //        HttpLevel,
    //        TcpLevel,
    //    }

    //    private Verb m_verb;
    //    private string m_name;

    //    /// <summary>
    //    /// Recycle an application pool.
    //    /// </summary>
    //    /// <param name="name">Name of the application pool.</param>
    //    [CommandMethod]
    //    public AppPool([CommandSwitch(Path = CommandPathInfo.Exists)]string name) {
    //        m_verb = Verb.Recycle;
    //        m_name = name;
    //    }

    //    ///// <summary>
    //    ///// Start an application pool.
    //    ///// </summary>
    //    ///// <param name="name">Name of the application pool.</param>
    //    //[CommandConstructor(Verb = "start")]
    //    //public AppPool(string name) {
    //    //    m_verb = Verb.Start;
    //    //    m_name = name;
    //    //}

    //    ///// <summary>
    //    ///// Stop an application pool.
    //    ///// </summary>
    //    ///// <param name="name">Name of the application pool.</param>
    //    //[CommandConstructor(Verb = "stop")]
    //    //public AppPool(string name) {
    //    //    m_verb = Verb.Stop;
    //    //    m_name = name;
    //    //}

    //    //[CommandConstructor(Verb = "remove")]
    //    //public AppPool(string name) {
    //    //    m_verb = Verb.Remove;
    //    //    m_name = name;
    //    //}

    //    private Version? m_version;
    //    private PipelineMode? m_pipelineMode;

    //    public AppPool(string name,
    //        Version? version = Version.v4,
    //        PipelineMode? pipelineMode = PipelineMode.Integrated) {

    //        m_verb = Verb.Add;
    //        m_name = name;
    //        m_version = version;
    //        m_pipelineMode = pipelineMode;
    //    }

    //    private int? m_cpuLimit;
    //    private LimitAction? m_cpuLimitAction;
    //    private int? m_cpuLimitInterval;
    //    private bool? m_cpuAffinityEnabled;
    //    private int? m_cpuAffinityMask;

    //    /// <summary>
    //    /// Configure CPU rationing and affinity.
    //    /// </summary>
    //    /// <param name="name">Name of the application pool.</param>
    //    /// <param name="limit">Max percentage (in 1/1000ths) of time CPU can be used over the limitInterval.</param>
    //    /// <param name="limitAction">Action to take if CPU ration is exceeded.</param>
    //    /// <param name="limitInterval">Time interval overwhich CPU ration is enforced.</param>
    //    /// <param name="affinityEnabled">If true then force the worker process to run on CPUs specified by the affinityMask.</param>
    //    /// <param name="affinityMask">A mask representing CPUs the worker process is allowed to use if affinityEnabled is true.</param>
    //    public AppPool(string name,
    //        int? limit = null,
    //        LimitAction? limitAction = null,
    //        int? limitInterval = null,
    //        bool? affinityEnabled = null,
    //        int? affinityMask = null) {

    //        m_cpuLimit = limit;
    //        m_cpuLimitAction = limitAction;
    //        m_cpuLimitInterval = limitInterval;
    //        m_cpuAffinityEnabled = affinityEnabled;
    //        m_cpuAffinityMask = affinityMask;
    //    }

    //    private int? m_processIdleTimeOut;
    //    private bool? m_processLoadUserProfile;
    //    private int? m_processMaxWorkingProcesses;
    //    private bool? m_processPingEnabled;
    //    private int? m_processPingTimeOut;
    //    private int? m_processPingPeriod;
    //    private int? m_processShutdownTimeOut;
    //    private int? m_processStartupTimeOut;

    //    /// <summary>
    //    /// Configure worker process startup, shutdown and idle time limits.
    //    /// </summary>
    //    /// <param name="name">Name of the application name.</param>
    //    /// <param name="idleTimeOut">Kill process if no new requests are recieved after so many minutes.</param>
    //    /// <param name="maxWorkingProcesses">Maximum number of worker processes.</param>
    //    /// <param name="pingEnabled">Enable heart beat monitoring.</param>
    //    /// <param name="pingTimeOut">Kill process if ping is not acknowledged after so many seconds.</param>
    //    /// <param name="pingPeriod">Number of seconds to periodically ping the process.</param>
    //    /// <param name="shutdownTimeOut">Kill process if it does not start up in so many seconds.</param>
    //    /// <param name="startupTimeOut">Kill process if it does not shut down in so many seconds.</param>
    //    public AppPool(string name,
    //        int? idleTimeOut = null,
    //        bool? loadUserProfile = null,
    //        int? maxWorkingProcesses = null,
    //        bool? pingEnabled = null,
    //        int? pingTimeOut = null,
    //        int? pingPeriod = null,
    //        int? shutdownTimeOut = null,
    //        int? startupTimeOut = null) {

    //        m_processIdleTimeOut = idleTimeOut;
    //        m_processLoadUserProfile = loadUserProfile;
    //        m_processMaxWorkingProcesses = maxWorkingProcesses;
    //        m_processPingEnabled = pingEnabled;
    //        m_processPingTimeOut = pingTimeOut;
    //        m_processPingPeriod = pingPeriod;
    //        m_processShutdownTimeOut = shutdownTimeOut;
    //        m_processStartupTimeOut = startupTimeOut;
    //    }

    //    private bool? m_debugEnabled;
    //    private string m_debugExe;
    //    private string m_debugArguments;

    //    /// <summary>
    //    /// Configure "Process Orphaning" commonly used to automatically attach a 
    //    /// debugger to an uresponsive process.
    //    /// </summary>
    //    /// <param name="name">Name of the application pool.</param>
    //    /// <param name="enabled">If true then instead of killing unresponsive processes "abandon" it and execute a command (e.g. attaching a debugger).</param>
    //    /// <param name="exe">Exe to run when a process is abandoned.</param>
    //    /// <param name="exeArguments">Arguments to the exe. "%1%" will be replaced by the process id.</param>
    //    public AppPool(string name,
    //        bool? enabled = null,
    //        string exe = null,
    //        string exeArguments = null) {

    //        m_debugEnabled = enabled;
    //        m_debugExe = exe;
    //        m_debugArguments = exeArguments;
    //    }

    //    private ServiceUnavailable? m_rapidFailServiceUnavailable;
    //    private bool? m_rapidFailEnabled;
    //    private int? m_rapidFailInterval;
    //    private int? m_rapidFailMaxFailures;
    //    private string m_shutdownExe;
    //    private string m_shutdownExeParameters;

    //    /// <summary>
    //    /// Configure "Rapid Fail Protection" to prevent restarting a processes if it
    //    /// failes a certain number of times in a given interval.
    //    /// </summary>
    //    /// <param name="name">Name of the application pool.</param>
    //    /// <param name="serviceUnavailable">How to respond to requests once the application pool is stopped.</param>
    //    /// <param name="enabled">Enable stopping the application pool if it fails a number of times in a given interval.</param>
    //    /// <param name="failureInterval">The interval in minutes in which if more than a number of failures occur to stop the process.</param>
    //    /// <param name="maxFailures">The number of failures to tolerate in a given interval before stopping the process.</param>
    //    /// <param name="shutdownExe">An exe to launch if the process is stopped (i.e. a load balancer).</param>
    //    /// <param name="shutdownExeParameters">Arguments to the exe.</param>
    //    public AppPool(string name,
    //        ServiceUnavailable? serviceUnavailable = null,
    //        bool? enabled = null,
    //        int? failureInterval = null,
    //        int? maxFailures = null,
    //        string shutdownExe = null,
    //        string shutdownExeParameters = null) {

    //        m_rapidFailServiceUnavailable = serviceUnavailable;
    //        m_rapidFailEnabled = enabled;
    //        m_rapidFailInterval = failureInterval;
    //        m_rapidFailMaxFailures = maxFailures;
    //        m_shutdownExe = shutdownExe;
    //        m_shutdownExeParameters = shutdownExeParameters;
    //    }

    //    private bool? m_synchronousRecycle;
    //    private bool? m_recycleOnNewConfig;
    //    private int? m_privateMemoryLimit;
    //    private int? m_regularTimeIntervals;
    //    private int? m_requestLimit;
    //    private int? m_virtualMemoryLimit;

    //    /// <summary>
    //    /// Configure how and when process recycling should happen.
    //    /// </summary>
    //    /// <param name="name">Name of the application pool.</param>
    //    /// <param name="synchronousRecycle">Ensure the old process exits before starting the new one.</param>
    //    /// <param name="recycleOnNewConfig">Recycle if the configuration changes.</param>
    //    /// <param name="privateMemoryLimit">The maximum amount of private memory a process can consume before it is recycled.</param>
    //    /// <param name="regularTimeIntervals">The period in minutes after which the process is recycled.</param>
    //    /// <param name="requestLimit">The number of requests a process can service before it is recycled.</param>
    //    /// <param name="virtualMemoryLimit">The maximum amount of virtual memory a process can consume before it is recycled.</param>
    //    public AppPool(string name,
    //        bool? synchronousRecycle = null,
    //        bool? recycleOnNewConfig = null,
    //        int? privateMemoryLimit = null,
    //        int? regularTimeIntervals = null,
    //        int? requestLimit = null,
    //        //DateTime[] specificTimes = null,
    //        int? virtualMemoryLimit = null) {

    //        m_synchronousRecycle = synchronousRecycle;
    //        m_recycleOnNewConfig = recycleOnNewConfig;
    //        m_privateMemoryLimit = privateMemoryLimit;
    //        m_regularTimeIntervals = regularTimeIntervals;
    //        m_requestLimit = requestLimit;
    //        m_virtualMemoryLimit = virtualMemoryLimit;
    //    }

    //    public AppPool(string name,
    //        bool? configuration = null,
    //        bool? isapiUnhealthy = null,
    //        bool? manualRecycle = null,
    //        bool? privateMemoryLimitExceeded = null,
    //        bool? regularTimeInterval = null,
    //        bool? requestTimeLimitExceeded = null,
    //        bool? specificTime = null,
    //        bool? virtualMemoryLimitExceeded = null) {
    //    }
    //}
}
